package com.lq.learningTest.duoxiancheng;

import java.util.concurrent.locks.LockSupport;

public class LockSupportTest {
    public static void main(String[] args) {
        Thread thread = new Thread(new Runnable() {
            public void run() {
                System.out.println(1);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(2);
                System.out.println("被park");
                LockSupport.park();
                System.out.println(3);
            }
        });
        thread.start();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);

        }
        System.out.println("五秒后unpark");
        LockSupport.unpark(thread);
    }
}
